/**
 * copyright (C), 2018-2019
 * fileName: MyMethodInterceptor
 * author:   hatricks
 * date:     2019-12-16 14:53
 * description: 我的方法拦截器
 */
package com.mybatispluslambda.cglib.proxy.demo;

import lombok.extern.slf4j.Slf4j;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 我的方法拦截器
 *
 * @author hatricks
 * @create 2019-12-16 14:53
 * @since 1.0.0
 */
@Slf4j
public class MyMethodInterceptor implements MethodInterceptor {

    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
        log.info("you said :" + Arrays.toString(args));

        return proxy.invokeSuper(obj, args);
    }

    public static void main(String[] args) {
        List<Integer> result = new ArrayList<>();
        result.add(1);
        result.add(2);
        result.add(3);
        result.add(4);

        System.out.println(result.stream().reduce(Integer::sum).get());
    }

}
